package com.flot.yazb.widget.vitamioPlayer;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.flot.yazb.R;
import com.flot.yazb.base.BActivity;

import io.vov.vitamio.LibsChecker;


public class VideoPlayActivity extends BActivity implements PlayVideoView {
    public final static String MEDIAS_ID_KEY = "media_id";
    private PlayVideoPresenter mPresenter;
    private String medias_id;
    private VideoControllerView contro;

    public static Intent createIntent(Context context, String id) {
        Intent intent = new Intent(context, VideoPlayActivity.class);
        intent.putExtra(MEDIAS_ID_KEY, id);
        return intent;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.activity_video_play);
        contro = (VideoControllerView) findViewById(R.id.videoControllerView);
        medias_id = getIntent().getStringExtra(MEDIAS_ID_KEY);
        mPresenter = new PlayVideoPresenterImpl(this);
        mPresenter.getMedia("http://video.baliup.com:88/m3u8//10/10.m3u8");
    }


    protected void start() {
        contro.start();
    }

    protected void pause() {
        contro.pause();
    }

    private void setHeaderView(String url) {
        contro.setVideoPath(url);
        contro.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        contro.release();
    }

    @Override
    public void setLinkUrl(String url) {
        setHeaderView(url);
    }

    @Override
    public void closeParentActivity() {

    }

}
